#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int signo = 0;

void handler(int signal)
{
	signo = signal;
}

int main(int argc, char **argv)
{
	sigset_t signalMask;
	if(sigfillset(&signalMask) == -1)
	{
		perror("sigfillset");
		return -1;
	}
	
	struct sigaction action;
	action.sa_handler = handler;
	action.sa_mask    = signalMask;
	action.sa_flags	  =  SA_RESTART;

	if(sigaction(SIGINT, &action, NULL) == -1)
	{
		perror("sigaction");
		return -1;
	}

	printf("Now I go sleeping!\n");

	while(sleep(60));

	return signo;
}
